//
//  TableViewDelegateSource.h
//  MutipleTableView
//
//  Created by admin on 2022/1/21.
//

#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN

@interface TableViewDelegateSource : NSObject  <UITableViewDelegate,UITableViewDataSource>

@property(nonatomic, copy)TableViewDelegateSource *(^numberOfRowsInSection)(NSInteger (^)(UITableView * tableView, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^cellForRowAtIndexPath)(UITableViewCell* (^)(UITableView * tableView, NSIndexPath* indexPath));


@property(nonatomic, copy)TableViewDelegateSource *(^numberOfSectionsInTableView)(NSInteger (^)(UITableView * tableView));
@property(nonatomic, copy)TableViewDelegateSource *(^titleForHeaderInSection)(NSString * (^)(UITableView * tableView, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^titleForFooterInSection)(NSString * (^)(UITableView * tableView, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^canEditRowAtIndexPath)(BOOL (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^canMoveRowAtIndexPath)(BOOL (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^sectionIndexTitlesForTableView)(NSArray<NSString *> * (^)(UITableView * tableView));

@property(nonatomic, copy)TableViewDelegateSource *(^sectionForSectionIndexTitle)(NSInteger (^)(UITableView * tableView, NSString *title,NSInteger index));

@property(nonatomic, copy)TableViewDelegateSource *(^commitEditingStyle)(NSInteger (^)(UITableView * tableView, UITableViewCellEditingStyle editingStyle,NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^moveRowAtIndexPath)(NSInteger (^)(UITableView * tableView, NSIndexPath * sourceIndexPath,NSIndexPath * destinationIndexPath));

#pragma mark - delegate - 常用delegate
// Display customization
@property(nonatomic, copy)TableViewDelegateSource *(^willDisplayCell)(void (^)(UITableView * tableView, UITableViewCell * cell, NSIndexPath* indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^willDisplayHeaderView)(void (^)(UITableView * tableView, UIView *view, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^willDisplayFooterView)(void (^)(UITableView * tableView, UIView * view, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^didEndDisplayingCell)(void (^)(UITableView * tableView, UITableViewCell * cell, NSIndexPath* indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^didEndDisplayingHeaderView)(void (^)(UITableView * tableView, UIView * view, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^didEndDisplayingFooterView)(void (^)(UITableView * tableView, UIView * view, NSInteger section));

// Variable height support
@property(nonatomic, copy)TableViewDelegateSource *(^heightForRowAtIndexPath)(CGFloat (^)(UITableView * tableView, NSIndexPath* indexPath));

@property(nonatomic, copy)TableViewDelegateSource *(^heightForHeaderInSection)(CGFloat (^)(UITableView * tableView, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^heightForFooterInSection)(CGFloat (^)(UITableView * tableView, NSInteger section));
// Use the estimatedHeight methods to quickly calculate guessed values which will allow for fast load times of the table.
// If these methods are implemented, the above -tableView:heightForXXX calls will be deferred until views are ready to be displayed, so more expensive logic can be placed there.
@property(nonatomic, copy)TableViewDelegateSource *(^estimatedHeightForRowAtIndexPath)(CGFloat (^)(UITableView * tableView, NSIndexPath* indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^estimatedHeightForHeaderInSection)(CGFloat (^)(UITableView* tableView, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^estimatedHeightForFooterInSection)(CGFloat (^)(UITableView * tableView, NSInteger section));


// Section header & footer information. Views are preferred over title should you decide to provide both
@property(nonatomic, copy)TableViewDelegateSource *(^viewForHeaderInSection)(UIView* (^)(UITableView* tableview, NSInteger section));
@property(nonatomic, copy)TableViewDelegateSource *(^viewForFooterInSection)(UIView* (^)(UITableView* tableview, NSInteger section));

// Accessories (disclosures).
@property(nonatomic, copy)TableViewDelegateSource *(^accessoryButtonTappedForRowWithIndexPath)(void (^)(UITableView * tableView, NSIndexPath * indexPath));
// Selection

// -tableView:shouldHighlightRowAtIndexPath: is called when a touch comes down on a row.
// Returning NO to that message halts the selection process and does not cause the currently selected row to lose its selected look while the touch is down.
@property(nonatomic, copy)TableViewDelegateSource *(^shouldHighlightRowAtIndexPath)(BOOL (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^didHighlightRowAtIndexPath)(void (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^didUnhighlightRowAtIndexPath)(void (^)(UITableView * tableView, NSIndexPath * indexPath));

// Called before the user changes the selection. Return a new indexPath, or nil, to change the proposed selection.
@property(nonatomic, copy)TableViewDelegateSource *(^willSelectRowAtIndexPath)(NSIndexPath * (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^willDeselectRowAtIndexPath)(NSIndexPath * (^)(UITableView * tableView, NSIndexPath * indexPath));
// Called after the user changes the selection.
@property(nonatomic, copy)TableViewDelegateSource *(^didSelectRowAtIndexPath)(void (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^didDeselectRowAtIndexPath)(void (^)(UITableView * tableView, NSIndexPath * indexPath));
// Editing

// Allows customization of the editingStyle for a particular cell located at 'indexPath'. If not implemented, all editable cells will have UITableViewCellEditingStyleDelete set for them when the table has editing property set to YES.
@property(nonatomic, copy)TableViewDelegateSource *(^editingStyleForRowAtIndexPath)(UITableViewCellEditingStyle (^)(UITableView * tableView,NSIndexPath * indexPath));

@property(nonatomic, copy)TableViewDelegateSource *(^titleForDeleteConfirmationButtonForRowAtIndexPath)(NSString * (^)(UITableView * tableView, NSIndexPath * indexPath));

// Swipe actions
// These methods supersede -editActionsForRowAtIndexPath: if implemented
// return nil to get the default swipe actions
@property(nonatomic, copy)TableViewDelegateSource *(^leadingSwipeActionsConfigurationForRowAtIndexPath)(UISwipeActionsConfiguration* (^)(UITableView * tableView, NSIndexPath * indexPath)) API_AVAILABLE(ios(11.0));
@property(nonatomic, copy)TableViewDelegateSource *(^trailingSwipeActionsConfigurationForRowAtIndexPath)(UISwipeActionsConfiguration* (^)(UITableView * tableView, NSIndexPath * indexPath)) API_AVAILABLE(ios(11.0));

// Controls whether the background is indented while editing.  If not implemented, the default is YES.  This is unrelated to the indentation level below.  This method only applies to grouped style table views.
@property(nonatomic, copy)TableViewDelegateSource *(^shouldIndentWhileEditingRowAtIndexPath)(BOOL (^)(UITableView * tableView, NSIndexPath * indexPath));
// The willBegin/didEnd methods are called whenever the 'editing' property is automatically changed by the table (allowing insert/delete/move). This is done by a swipe activating a single row
@property(nonatomic, copy)TableViewDelegateSource *(^willBeginEditingRowAtIndexPath)(NSInteger (^)(UITableView * tableView, NSIndexPath * indexPath));
@property(nonatomic, copy)TableViewDelegateSource *(^didEndEditingRowAtIndexPath)(void (^)(UITableView * tableView, NSIndexPath * indexPath));

// Moving/reordering

// Allows customization of the target row for a particular row as it is being moved/reordered
@property(nonatomic, copy)TableViewDelegateSource *(^targetIndexPathForMoveFromRowAtIndexPath)(NSIndexPath * (^)(UITableView * tableView, NSIndexPath * sourceIndexPath, NSIndexPath * proposedDestinationIndexPath));
// Indentation
@property(nonatomic, copy)TableViewDelegateSource *(^indentationLevelForRowAtIndexPath)(NSInteger (^)(UITableView * tableView, NSIndexPath * indexPath));

// Copy/Paste.  All three methods must be implemented by the delegate.
//- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath API_DEPRECATED_WITH_REPLACEMENT("tableView:contextMenuConfigurationForRowAtIndexPath:point:", ios(5.0, 13.0));
//..
// Focus
@property(nonatomic, copy)TableViewDelegateSource *(^canFocusRowAtIndexPath)(BOOL (^)(UITableView * tableView, NSIndexPath * indexPath)) API_AVAILABLE(ios(9.0));
@property(nonatomic, copy)TableViewDelegateSource *(^shouldUpdateFocusInContext)(BOOL (^)(UITableView * tableView, UITableViewFocusUpdateContext* context)) API_AVAILABLE(ios(9.0));

@property(nonatomic, copy)TableViewDelegateSource *(^didUpdateFocusInContext)(void (^)(UITableView * tableView, UITableViewFocusUpdateContext * context, UIFocusAnimationCoordinator * coordinator)) API_AVAILABLE(ios(9.0));
@property(nonatomic, copy)TableViewDelegateSource *(^indexPathForPreferredFocusedViewInTableView)(NSIndexPath * (^)(UITableView * tableView)) API_AVAILABLE(ios(9.0));

/// Determines if the row at the specified index path should also become selected when focus moves to it.
/// If the table view's global selectionFollowsFocus is enabled, this method will allow you to override that behavior on a per-index path basis. This method is not called if selectionFollowsFocus is disabled.
@property(nonatomic, copy)TableViewDelegateSource *(^selectionFollowsFocusForRowAtIndexPath)(BOOL (^)(UITableView * tableView, NSIndexPath * indexPath));

- (instancetype)initWithTableView:(UITableView *)tableView;
@end

NS_ASSUME_NONNULL_END
